<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>全部节点</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="stylesheet" type="text/css" href="../../css/sm.min.css">
    <link rel="stylesheet" type="text/css" href="../../css/normal.css" />
    <link rel="stylesheet" type="text/css" href="../../css/allNode.css" />
    <link rel="stylesheet" type="text/css" href="../../iconfont/iconfont.css" />
</head>

<body>
    <div class="page allWarp">
        <div class="content">
            <div class="trackList" v-if="nodeData.length != '0'" style="margin-bottom: 3rem;">
                <ul class="trackListUl">
                    <li v-for="item in nodeData"> 
                        
                        <p class="font12 col999 lineheight20 dot around" :class="item.status == 2 ? 'colorange':'col999'">
                            <span>
                                <span v-text="item.nodeName"></span>
                                <span>
                                    负责人：
                                    <span v-for="items in item.nodeDutyList">
                                        <span v-text="items.dutyUser" class="right10"></span>
                                    </span>
                                </span>
                            </span>
                            <span v-if="status == 1">
                                <i class="iconfont icon-shanchu" onclick="deleteNode()" :data-nodeCode="item.nodeCode"></i>
                                <i class="iconfont icon-bianji" onclick="editNode()" :data-nodeCodes="item.nodeCode"></i>
                            </span>
                        </p>
                    </li>
                </ul>
            </div>
            <div class="addNode" v-if="status == 1">
                <span onclick="back()" class="width50" style="border-right: 1px solid #e1e1e1">返回详情</span>
                <span onclick="moveTo('newNode')" class="width50">添加节点</span>
            </div>
        </div>
    </div>
    <script type="text/javascript" src="../../js/zepto.js"></script>
    <script type="text/javascript" src="../../js/sm.min.js"></script>
    <script type="text/javascript" src="../../js/vue.min.js"></script>
    <script type="text/javascript" src="../../js/ajax.js"></script>
    <script type="text/javascript" src="../../js/back.js"></script>
    <script type="text/javascript">
        var projectCode = GetQueryString("projectCode");
        var role = GetQueryString("role");
        var keyN = JSON.parse(getCookie("user_data_two"));
        var createUid;
        var customerPhone;
        if (keyN != null) {
            createUid = keyN.userId;
        }
        var demo = new Vue({
            el: '.allWarp',
            data: {
                nodeData: '',
            },
            beforeCreate: function() {
                setTimeout(function(){
                    init();
                },100)
            }
        })
        // 节点列表
        function nodeList(){
            var params = {};
            params.projectCode = projectCode;
            kfAjaxGet.nodeList(params, function(json) {
                if (json.code == 200) {
                    demo.nodeData = json.data;
                    console.log(json.data)
                } else if (checkcode(json.code)) {

                } else {
                    $.toast(json.message);
                }
            })
        }

        function init(){
            var params = {};
            params.projectCode = projectCode;
            kfAjaxGet.projectDetail(params, function(json) {
                if (json.code == 200) {
                    var data = json.data;
                    demo.status = data.status;
                    nodeList();
                } else if (checkcode(json.code)) {

                } else {
                    $.toast(json.message);
                }
            })
        }

        //删除节点
        function deleteNode(){
            var _that = $(event.currentTarget);
            var nodeCode = _that.attr("data-nodeCode");
            var params = {};
            params.nodeCode = nodeCode;
            params.updateUid = createUid;
            kfAjaxGet.deleteNode(params, function(json) {
                if (json.code == 200) {
                   history.go(0);
                } else if (checkcode(json.code)) {

                } else {
                    $.toast(json.message);
                }
            })
        }

        //编辑节点
        function editNode(){
            var _that = $(event.currentTarget);
            var nodeCode = _that.attr("data-nodeCodes");
            console.log(nodeCode)
            window.location = 'addPoint.html?projectCode='+projectCode+'&nodeCode='+nodeCode+'&isNewNode=false'+'&come=an'+'&role='+role;   
        }

        // 跳转
        function moveTo(val){
            if(val == "newNode"){
                sessionStorage.removeItem('node_data');
                sessionStorage.removeItem('nodeSaler_data');
                window.location = 'addPoint?isNewNode=true&projectCode='+projectCode+'&come=an'+'&role='+role;
            }
        }

        function back(){
            window.location = 'projectDetail.html?projectCode='+projectCode+'&showDetail=2'+'&role='+role;
        }

        $(function(){
            $('#gohome').on('click',function(){
                window.location = 'myProject.html?role='+role;
            })
        })
    </script>
</body>
</html>